<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>范例</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="gmagick.constants.html">« 预定义常量</a></li>
      <li style="float: right;"><a href="class.gmagick.html">Gmagick »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.gmagick.html">Gmagick</a></li>
    <li>范例</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="gmagick.examples" class="chapter">
 <h1>范例</h1>

 <p class="para">
  The following shows some common Gmagick image operations.
 </p>
 <div class="example" id="example-2721">
  <p><strong>示例 #1 Gmagick Example</strong></p>
  <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//Instantiate&nbsp;a&nbsp;new&nbsp;Gmagick&nbsp;object<br /></span><span style="color: #0000BB">$image&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Gmagick</span><span style="color: #007700">(</span><span style="color: #DD0000">'example.jpg'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//Make&nbsp;thumbnail&nbsp;from&nbsp;image&nbsp;loaded.&nbsp;0&nbsp;for&nbsp;either&nbsp;axes&nbsp;preserves&nbsp;aspect&nbsp;ratio<br /></span><span style="color: #0000BB">$image</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">thumbnailimage</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//Create&nbsp;a&nbsp;border&nbsp;around&nbsp;the&nbsp;image,&nbsp;then&nbsp;simulate&nbsp;how&nbsp;the&nbsp;image&nbsp;will&nbsp;look&nbsp;like&nbsp;as&nbsp;an&nbsp;oil&nbsp;painting<br />//Notice&nbsp;the&nbsp;chaining&nbsp;of&nbsp;mutator&nbsp;methods&nbsp;which&nbsp;is&nbsp;supported&nbsp;in&nbsp;gmagick<br /></span><span style="color: #0000BB">$image</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">borderimage</span><span style="color: #007700">(</span><span style="color: #DD0000">"yellow"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">8</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">8</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">oilpaintimage</span><span style="color: #007700">(</span><span style="color: #0000BB">0.3</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//Write&nbsp;the&nbsp;current&nbsp;image&nbsp;at&nbsp;the&nbsp;current&nbsp;state&nbsp;to&nbsp;a&nbsp;file<br /></span><span style="color: #0000BB">$image</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">write</span><span style="color: #007700">(</span><span style="color: #DD0000">'example_thumbnail.jpg'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
  </div>

 </div>
</div>
</div></div></body></html>